<template>
  <div class="home">
    <div class="wrapper actions">
      <!--      <el-button type="success" icon="el-icon-tickets" round>填报历史</el-button>-->
      <el-button type="primary" icon="el-icon-plus" round @click="submitDataVisible=true">填报数据</el-button>
    </div>
    <div class="wrapper container">
      <el-empty v-show="!time" description="填报数据后会自动生成图表"/>
      <Chart v-show="time" :time="time" :rows="rows"/>
    </div>
    <SubmitData :visible.sync="submitDataVisible" @success="onSubmit"/>
  </div>
</template>

<script>
  import SubmitData from "./components/SubmitData";
  import Chart from "./components/Chart";

  export default {
    name: 'HomeView',
    components: {Chart, SubmitData},
    data() {
      return {
        submitDataVisible: false,
        time: '',
        rows: null
      }
    },
    methods: {
      onSubmit({time, rows}) {
        this.time = time
        this.rows = rows
      },
    }
  }
</script>

<style lang="less" scoped>
  .home {
    display: flex;
    flex-direction: column;
    gap: 20px 0;

    .wrapper {
      box-shadow: 0 0 5px rgba(0, 0, 0, .3);
      padding: 10px;
      border-radius: 8px;
      border: 1px solid #e5e5e5;
    }

    .actions {
      display: flex;
      flex-direction: row;
      align-items: center;
    }

    .container {
      flex: 1;
    }
  }
</style>